/*
 * Title:        CloudScheduler Toolkit
 * Description:  a Toolkit for Modeling and Simulation of Job Scheduling and Resource Provisioning in Cloud System
 * Licence:      GPL - http://www.gnu.org/copyleft/gpl.html
 * Author:       Fuhui Wu
 *
 * Copyright (c) 2013-2014, The National University of Defense Technology, China
 */

package org.nudt.jCloud.example.resourceStealing2;

import java.util.List;

import org.nudt.jCloud.infrastructure.Cluster;
import org.nudt.jCloud.simulation.Framework;
import org.nudt.jCloud.simulation.ScaleData;

public class HeuristicPreemptionRM extends StealingRM{

	public HeuristicPreemptionRM(String name, Cluster cluster, int totalSlotNum) {
		super(name, cluster);
		setTotalSlotNum(totalSlotNum);
	}
					
	@Override
	public void scaleResource(List<ScaleData> scaleDataList) {
		List<Framework > requestFrwkList = requestFrwk(scaleDataList);
		if(isInitialized() == false){
			initSlotRatio();
		}
		lease(scaleDataList);		
		
		stealFromNoReq(requestFrwkList, scaleDataList);
		stealFromReqSatisfied(scaleDataList);
		stealFromReqOverThresh(scaleDataList);	
		
		preempt(requestFrwkList, scaleDataList);	
	}
	
}
